Load point data

sb_tweets <- read_sf("data/sb-tweets.shp")

head(sb_tweets)
## Simple feature collection with 6 features and 6 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: -119.8908 ymin: 34.42285 xmax: -119.632 ymax: 34.4337
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
## # A tibble: 6 x 7
##   Month   Day  Year fll_txt            usr_lct  usr_typ                 geometry
##   <chr> <dbl> <dbl> <chr>              <chr>    <chr>                <POINT [°]>
## 1 Nov      29  2019 "santa maria styl~ 805      tourist       (-119.714 34.4258)
## 2 Nov      29  2019 "?well she's wash~ world w~ tourist       (-119.632 34.4337)
## 3 Nov      29  2019 "i pray everyone ~ Chicago~ tourist       (-119.632 34.4337)
## 4 Nov      30  2019 ".\nlet my speech~ Santa B~ local       (-119.8908 34.42285)
## 5 Nov      30  2019 "#paleo #bananacr~ Santa B~ local         (-119.714 34.4258)
## 6 Nov      29  2019 "only family phot~ Califor~ tourist       (-119.714 34.4258)
mapview(sb_tweets)

Play with some color

mapview(sb_tweets, zcol = "usr_typ")

Can also map continuous data

mapview(sb_tweets, zcol = "Day")

Polygon data

#cpad = california protected area database

cpad <- read_sf("data/ca_protected_areas.shp")

#zcol allows you to symbolize based on a field, 
# burst allows you to separate into separate layers
mapview(cpad, zcol = "ACCESS_TYP", burst = TRUE) 

Apply your own colors using col.regions

# mapview(cpad, zcol = "ACCESS_TYP", col.regions = c("purple","yellow","darkgreen","orange"))

mapview(cpad, zcol = "ACCESS_TYP", col.regions = mapviewPalette("mapviewSpectralColors"))

Combine Layers

mapview(cpad, zcol = "ACCESS_TYP", layer.name = "CPAD Access") +
  mapview(sb_tweets, zcol = "usr_typ", layer.name = "SB Tweets")

Raster Data

catch <- raster("data/catch_2015.tif")

mapview(catch)
## Warning in rasterCheckSize(x, maxpixels = maxpixels): maximum number of pixels for Raster* viewing is 5e+05 ; 
## the supplied Raster* has 720000 
##  ... decreasing Raster* resolution to 5e+05 pixels
##  to view full resolution set 'maxpixels =  720000 '

Save

sb_map <- mapview(cpad, zcol = "ACCESS_TYP", layer.name = "CPAD Access") +
  mapview(sb_tweets, zcol = "usr_typ", layer.name = "SB Tweets")

#save using `mapshot`

mapshot(sb_map, file = "sb_tweet_map.html")